package com.fancy.learncenter.view;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bigkoo.pickerview.OptionsPickerView;
import com.fancy.learncenter.activity.TzDetailActivity;
import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.BaseDataBean;
import com.fancy.learncenter.bean.EducationDataBean;
import com.fancy.learncenter.bean.JsonBean;
import com.fancy.learncenter.common.MyApplication;
import com.fancy.learncenter.net.HttpMehtod;
import com.fancy.learncenter.net.IdeaObserver;
import com.fancy.learncenter.utils.DimenUtil;
import com.fancy.learncenter.utils.GetJsonDataUtil;
import com.fancy.learncenter.utils.ToastUtil;
import com.fancy.learncenter.utils.WXShareUtil;
import com.google.gson.Gson;
import com.superservice.lya.R;

import org.json.JSONArray;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by hyy on 2018/2/24.
 * Explain activity as
 */

public class PopupWindowShare {

    View locationView;

    View popopView;

    View viewParent;

    RecyclerView recyclerView;

    Activity mContext;


    LPopWindow lPopWindow;

    public PopupWindowShare(Context mContext, View viewParent) {
        this.viewParent = viewParent;

        View contentView = LayoutInflater.from(mContext).inflate(R.layout.pupopwinodw_share, null);
        TextView cancel = (TextView) contentView.findViewById(R.id.cancel);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                lPopWindow.dismiss();
            }
        });
        TextView weixin = (TextView) contentView.findViewById(R.id.weixin);
        weixin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                ToastUtil.show("微信");
                onClickCallBack.wxCallBack();
                lPopWindow.dismiss();
            }
        });
        TextView quan = (TextView) contentView.findViewById(R.id.quan);
        quan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                ToastUtil.show("朋友圈");
                onClickCallBack.wxFriendCallBack();
                lPopWindow.dismiss();
            }
        });
        lPopWindow = new LPopWindow.Builder(mContext)
                .setView(contentView)
                .size(ViewGroup.LayoutParams.MATCH_PARENT, DimenUtil.dip2px(200))
                .enableBackgroundDark(true) //弹出popWindow时，背景是否变暗
                .setBgDarkAlpha(0.7f) // 控制亮度
                .build();
    }

    public void showAtLocation() {
        lPopWindow.showAtLocation(viewParent, Gravity.BOTTOM, 0, 0);
    }


    public OnClickCallBack getOnClickCallBack() {
        return onClickCallBack;
    }

    public void setOnClickCallBack(OnClickCallBack onClickCallBack) {
        this.onClickCallBack = onClickCallBack;
    }

    private OnClickCallBack onClickCallBack;

    public interface OnClickCallBack {
        abstract void wxFriendCallBack();

        abstract void wxCallBack();
    }

}
